package NGUYENNGOCHUNG;

import java.util.Scanner;

public class Ptb2 {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		System.out
				.println("Bai tap gia phuong trinh bac 2:  ax2+ + bx + c = 0 ");

		System.out.println("Vui long nhap vao so a: ");
		double a = scan.nextDouble();

		scan = new Scanner(System.in);
		System.out.println("Vui long nhap vao so b: ");
		double b = scan.nextDouble();

		scan = new Scanner(System.in);
		System.out.println("Vui long nhap vao so c: ");
		double c = scan.nextDouble();

		double delta = b * b - 4 * a * c;
		double x1 = ((-b) + Math.sqrt(delta)) / 2 * a;
		double x2 = ((-b) - Math.sqrt(delta)) / 2 * a;

		if (a == 0) {
		}
		else if (b == 0) {
			System.out.println("phuong trinh vo nghiem");
		} else if (b != 0) {
			System.out.println("phuong trinh co nghiem x = " + (-c / b));
		} else if ((b == 0) && (c == 0)) {
			System.out.println("phuong trinh co vo so nghiem");
		} else {

		}
		if (delta < 0) {
			System.out.println("phuong trinh vo nghiem");
		} else if (delta == 0) {
			System.out.println("phuong trinh co nghiem kep x1 = x2 = "
					+ ((-b) / 2 * a));
		} else if (delta > 0) {
			System.out.println("phuong trinh co 2 nghiem phan biet x1 = " + x1
					+ "va x2 = " + x2);

		}
	}
}
